/**
 * creation: 22-apr-2008
 */
package org.jfonia.structure;

import org.jfonia.connect.BasicNode;
import org.jfonia.connect.Node;
import org.jfonia.connect.SimpleValue;
import org.jfonia.connect.Value;
import org.jfonia.connect.arithmetic.ConstantIntAddition;
import org.jfonia.connect.arithmetic.Incrementor;
import org.jfonia.connect.logic.IfElse;
import org.jfonia.connect.logic.IntLessThan;

/**
 * @author wijnand.schepens@gmail.com
 * 
 */
public class TrivialIntIterator implements IntIterator
{
	private SimpleValue<Integer> value;
	private Value<Integer>       stopValue;
	private Value<Integer>       lookaheadValue;
	private Node                 proceeder;
	private Value<Boolean>       proceedCondition;
	
	public TrivialIntIterator(int start, int stop)   // [start, stop]
	{
		this.value = new SimpleValue<Integer>(start);
		this.lookaheadValue = new ConstantIntAddition(value, 1);
		this.stopValue = new SimpleValue<Integer>(stop);
		this.proceedCondition = new IntLessThan(getLookaheadValue(), stopValue);
		this.proceeder = new IfElse(getProceedCondition(), new Incrementor(value) );
			
	}

	public Value<Integer> getValue()
	{
		return this.value;
	}

	public Value<Integer> getLookaheadValue()
	{
		return this.lookaheadValue;
	}

	public Node getProceeder()
	{
		return this.proceeder;
	}
	
	public Value<Boolean> getProceedCondition()
	{
		return this.proceedCondition;
	}
	
}
